Object.defineProperty(exports, "__esModule", {
    value: !0
});

exports.default = {
    onStart: function(t) {
        var i = t.touches, h = this.boxWidth, s = this.boxHeight, a = i[0], e = a.x, n = a.y;
        e > h - 80 && s - 20 < n || (this.move = 1 === i.length, this.move && (this.startX = e, 
        this.startY = n, this.situ = !0));
    },
    onMove: function(t) {
        var i = t.touches;
        if (this.move) {
            var h = i[0].x - this.startX, s = i[0].y - this.startY;
            (Math.abs(h) > 4 || Math.abs(s) > 4) && (this.situ = !1), this.translate(h, s);
        }
    },
    onEnd: function() {
        this.move && this.situ && this.takeShot(), this.move = !1;
    },
    rotateImage: function() {
        this.rotate();
    },
    init: function() {
        var t = wx.getSystemInfoSync(), i = t.windowWidth, h = t.windowHeight, s = i - 20, a = Math.ceil(.37 * h - 20), e = Math.ceil(1920 * s / 1080), n = Math.ceil((s - a) / 2);
        this.imgWidth = s, this.imgHeight = e, this.dis = n, this.boxWidth = s, this.boxHeight = a;
    },
    start: function() {
        this.index = 2, this.rotate();
    },
    rotate: function() {
        this.index += 1;
        var t = this.index, i = this.boxWidth, h = this.boxHeight, s = this.dis, a = 0, e = 0;
        switch (t % 4) {
          case 1:
            a = s + h, e = -s;
            break;

          case 2:
            a = i, e = h;
            break;

          case 3:
            a = s, e = s + h;
        }
        this.x = a, this.y = e, this.repaint(a, e);
    },
    translate: function(t, i) {
        var h = this.index, s = this.boxWidth, a = this.boxHeight, e = this.imgHeight;
        this.ctx.clearRect(0, 0, s, a);
        var n = void 0, o = void 0;
        switch (h % 4) {
          case 0:
            n = this.x, o = this.y + i, o = Math.min(o, (e - a) / 2), o = Math.max(o, -a);
            break;

          case 1:
            n = this.x + t, n = Math.max(n, s - a), n = Math.min(n, (e - a) / 2 + a), o = this.y + i, 
            o = Math.min(o, 0), o = Math.max(o, a - s);
            break;

          case 2:
            n = this.x, o = this.y + i, o = Math.min(o, (e - a) / 2 + a), o = Math.max(o, 0);
            break;

          case 3:
            n = this.x + t, n = Math.max(n, (e - s) / 2 - a), n = Math.min(n, a), o = this.y + i, 
            o = Math.max(o, a), o = Math.min(o, s);
        }
        this.x = n, this.y = o, this.repaint(n, o);
    },
    repaint: function(t, i) {
        var h = this.index, s = this.boxWidth, a = this.boxHeight, e = this.imgWidth, n = this.imgHeight, o = this.ctx;
        o.clearRect(0, 0, s, a), o.translate(t, i), o.rotate(h % 4 * 90 * Math.PI / 180), 
        o.drawImage(this.data.shotImage, 0, (a - n) / 2, e, n), o.draw();
    }
};